/**
 * ----------------------------------------------------------------------------
 * Copyright Jens Konopka
 * 
 * Alle Rechte vorbehalten.
 * Licence: Apache 2.0
 * ----------------------------------------------------------------------------
 *
 * created on 02.03.2012 by jkonopka
 */
package de.sql.toolkit.util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Util class for static util methods by sql handling.<br>
 * 
 * @author jkonopka
 * 
 */
public final class SqlUtil {

	/**
	 * Hide the public constructor for this util class.
	 */
	private SqlUtil() {
	}

	/**
	 * Close the Connection.
	 * 
	 * @param closeable
	 * @throws Exception
	 */
	public static void close(final Connection closeable) throws Exception {
		if (closeable != null) {
			closeable.close();
		}
	}

	/**
	 * Close the Statement.
	 * 
	 * @param closeable
	 * @throws Exception
	 */
	public static void close(final Statement closeable) throws Exception {
		if (closeable != null) {
			closeable.close();
		}
	}

	/**
	 * Close the ResultSet.
	 * 
	 * @param closeable
	 * @throws Exception
	 */
	public static void close(final ResultSet closeable) throws Exception {
		if (closeable != null) {
			closeable.close();
		}
	}

	/**
	 * Close the Connection and the Statement.
	 * 
	 * @param connection
	 * @param statement
	 * @throws Exception
	 */
	public static void close(final Connection connection, final Statement statement) throws Exception {
		close(statement);
		close(connection);
	}

	/**
	 * Close the Connection, the Statement and the ResultSet.<br>
	 * 
	 * @param connection
	 * @param statement
	 * @throws Exception
	 */
	public static void close(final Connection connection, final Statement statement, final ResultSet result)
			throws Exception {
		close(result);
		close(statement);
		close(connection);
	}

}
